import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 存储token
    Authorization: localStorage.getItem('token') ? localStorage.getItem('token') : '',
    UserInfo: localStorage.getItem('user') ? localStorage.getItem('user') : '',
    LoginIP: localStorage.getItem('ip') ? localStorage.getItem('ip') : '',
    I18nLang: localStorage.getItem('lang') ? localStorage.getItem('lang') : 'zh-CN',
  },
  getters: {},
  mutations: {
    //注册处理函数，在login组件的login方法上使用this.$store.commit('login',data);
    login(state, token) {
      state.Authorization = token;
      localStorage.setItem('token', token)
    },
    user(state, user) {
      state.UserInfo = user;
      localStorage.setItem('user', user)
    }
  },
  actions: {},
  modules: {}
})